<?php
Authenticate::requireTechnic();
try {
    $pdo = Db::getPDO();
    $db = Db::getInstance();

	$packages = $pdo->query("SELECT * FROM Package WHERE status=1")->fetchAll(PDO::FETCH_ASSOC);
    Table::instanceTable('Price')->joinTo('price', 'packageId', 'id', $packages, Table::JOIN_MANY);

    $products = Product::instance()->get(null, array('order'=> 'createTime DESC'));
    Table::instanceTable('Package')->joinTo('package', 'id', 'packageId', $products, Table::JOIN_ONE);
    Table::instanceTable('Account')->joinTo('account', 'id', 'accountId', $products, Table::JOIN_ONE);

	View::display('technic/product', array('packages'=> $packages, 'products'=> $products));
} catch(Exception $e) {
    echo $e;
    throw $e;
}